import lark_oapi as lark
from lark_oapi.api.contact.v3 import *


APP_ID = 'cli_a637dde6d6b91013'
APP_SECRET = 'yp2YJICAuSIzz9v08Fo7Ve0sFDon2PlB'
# # 创建client
client = lark.Client.builder().app_id(APP_ID).app_secret(APP_SECRET).log_level(lark.LogLevel.DEBUG).build()
#
# # 构造请求对象
# request = lark.contact.v3.GetUserRequest.builder().user_id("7be5fg9a").build()
#
# # 发起请求
# response = client.contact.v3.user.get(request)
# print(response.data)

# Code generated by Lark OpenAPI.


# 构造请求对象
request: BatchGetIdUserRequest = BatchGetIdUserRequest.builder() \
    .user_id_type("union_id") \
    .request_body(BatchGetIdUserRequestBody.builder()
                  .mobiles(["15933983339"])
                  .build()) \
    .build()

# 发起请求
response: BatchGetIdUserResponse = client.contact.v3.user.batch_get_id(request)

# 处理失败返回
if not response.success():
    lark.logger.error(
        f"client.contact.v3.user.batch_get_id failed, code: {response.code}, msg: {response.msg}, log_id: {response.get_log_id()}")

# 处理业务结果
lark.logger.info(lark.JSON.marshal(response.data, indent=4))